import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/page/layout/Layout'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '',
    component: Layout,
    redirect: '/dashboard'
  },
  {
    path: '/login',
    component: () => import('@/page/login/login'),
    name: 'login',
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/page/errorPage/401'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/page/errorPage/404'),
    hidden: true
  },
  {
    path: '/dashboard',
    component: Layout,
    sidebar: true,
    meta: { title: '首页', icon: 'dashboard' },
    children: [
      {
        path: '',
        name: 'dashboard',
        sidebar: true,
        component: () => import('@/page/dashboard/Dashboard'),
        meta: { title: '首页', icon: 'dashboard', breadCrumb: true }
      }
    ]
  }
  // {
  //   path: '/testWebSocket',
  //   component: Layout,
  //   sidebar: true,
  //   meta: { title: '首页', icon: 'test' },
  //   children: [
  //     {
  //       path: '',
  //       name: 'test',
  //       sidebar: true,
  //       component: () => import('@/page/html1'),
  //       meta: { title: '测试', icon: 'test', breadCrumb: true }
  //     }
  //   ]
  // }
]

export default new Router({
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/product',
    component: Layout,
    name: 'product',
    alwaysShow: true,
    sidebar: true,
    meta: { title: '金融产品管理', icon: 'product', authKey: 'product' },
    children: [
      {
        path: 'presentProduct',
        name: 'presentProduct',
        sidebar: true,
        component: () => import('@/page/product/presentProduct'),
        meta: { title: '融资租赁-现车', icon: 'product', authKey: 'lease-present', breadCrumb: true }
      },
      // {
      //   path: 'singleProduct',
      //   name: 'singleProduct',
      //   sidebar: true,
      //   component: () => import('@/page/product/singleProduct'),
      //   meta: { title: '融资租赁-单采', icon: 'product', authKey: 'lease-single', breadCrumb: true }
      // },
      {
        path: 'newCarProduct',
        name: 'newCarProduct',
        sidebar: true,
        component: () => import('@/page/product/newCarProduct'),
        meta: { title: '金融分期-新车', icon: 'product', authKey: 'instalment-new', breadCrumb: true }
      },
      {
        path: 'secondCarProduct',
        name: 'secondCarProduct',
        sidebar: true,
        component: () => import('@/page/product/secondCarProduct'),
        meta: { title: '金融分期-二手', icon: 'product', authKey: 'instalment-second', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/presentProduct',
    component: Layout,
    redirect: '/product/presentProduct',
    meta: { title: '融资租赁-现车', breadCrumb: true },
    children: [
      {
        path: 'new',
        name: 'newPresentProduct',
        component: () => import('@/page/product/presentProduct/info'),
        meta: { title: '新增融资租赁-现车', authKey: 'lease-present-new', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/presentProduct',
    component: Layout,
    redirect: '/product/presentProduct',
    meta: { title: '融资租赁-现车', breadCrumb: true },
    children: [
      {
        path: 'modify/:productId',
        name: 'modifyPresentProduct',
        props: true,
        component: () => import('@/page/product/presentProduct/info'),
        meta: { title: '修改融资租赁-现车', authKey: 'lease-present-modify', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/presentProduct',
    component: Layout,
    redirect: '/product/presentProduct',
    meta: { title: '融资租赁-现车', breadCrumb: true },
    children: [
      {
        path: 'detail/:productId',
        name: 'presentDetail',
        props: true,
        component: () => import('@/page/product/presentProduct/detail'),
        meta: { title: '融资租赁-现车详情', authKey: 'lease-present-detail', breadCrumb: true }
      }
    ]
  },
  // {
  //   path: '/product/singleProduct',
  //   component: Layout,
  //   redirect: '/product/singleProduct',
  //   meta: { title: '融资租赁-单采', breadCrumb: true },
  //   children: [
  //     {
  //       path: 'new',
  //       name: 'newSingleProduct',
  //       component: () => import('@/page/product/singleProduct/info'),
  //       meta: { title: '新增融资租赁-单采', authKey: 'lease-single-new', breadCrumb: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/product/singleProduct',
  //   component: Layout,
  //   redirect: '/product/singleProduct',
  //   meta: { title: '融资租赁-单采', breadCrumb: true },
  //   children: [
  //     {
  //       path: 'modify/:productId',
  //       name: 'modifySingleProduct',
  //       props: true,
  //       component: () => import('@/page/product/singleProduct/info'),
  //       meta: { title: '修改融资租赁-单采', authKey: 'lease-single-modify', breadCrumb: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/product/singleProduct',
  //   component: Layout,
  //   redirect: '/product/singleProduct',
  //   meta: { title: '融资租赁-单采', breadCrumb: true },
  //   children: [
  //     {
  //       path: 'detail/:productId',
  //       name: 'singleDetail',
  //       props: true,
  //       component: () => import('@/page/product/singleProduct/detail'),
  //       meta: { title: '融资租赁-单采详情', authKey: 'lease-single-detail', breadCrumb: true }
  //     }
  //   ]
  // },
  {
    path: '/product/newCarProduct',
    component: Layout,
    redirect: '/product/newCarProduct',
    meta: { title: '金融分期-新车', breadCrumb: true },
    children: [
      {
        path: 'new',
        name: 'newNewCarProduct',
        component: () => import('@/page/product/newCarProduct/info'),
        meta: { title: '新增金融分期-新车', authKey: 'instalment-new-new', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/newCarProduct',
    component: Layout,
    redirect: '/product/newCarProduct',
    meta: { title: '金融分期-新车', breadCrumb: true },
    children: [
      {
        path: 'modify/:productId',
        name: 'modifyNewCarProduct',
        props: true,
        component: () => import('@/page/product/newCarProduct/info'),
        meta: { title: '修改金融分期-新车', authKey: 'instalment-new-modify', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/newCarProduct',
    component: Layout,
    redirect: '/product/newCarProduct',
    meta: { title: '金融分期-新车', breadCrumb: true },
    children: [
      {
        path: 'detail/:productId',
        name: 'newCarDetail',
        props: true,
        component: () => import('@/page/product/newCarProduct/detail'),
        meta: { title: '金融分期-新车详情', authKey: 'instalment-new-detail', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/secondCarProduct',
    component: Layout,
    redirect: '/product/secondCarProduct',
    meta: { title: '金融分期-二手', breadCrumb: true },
    children: [
      {
        path: 'new',
        name: 'newSecondCarProduct',
        component: () => import('@/page/product/secondCarProduct/info'),
        meta: { title: '新增金融分期-二手', authKey: 'instalment-second-new', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/secondCarProduct',
    component: Layout,
    redirect: '/product/secondCarProduct',
    meta: { title: '金融分期-二手', breadCrumb: true },
    children: [
      {
        path: 'modify/:productId',
        name: 'modifysecondCarProduct',
        props: true,
        component: () => import('@/page/product/secondCarProduct/info'),
        meta: { title: '修改金融分期-二手', authKey: 'instalment-second-modify', breadCrumb: true }
      }
    ]
  },
  {
    path: '/product/secondCarProduct',
    component: Layout,
    redirect: '/product/secondCarProduct',
    meta: { title: '金融分期-二手', breadCrumb: true },
    children: [
      {
        path: 'detail/:productId',
        name: 'secondCarDetail',
        props: true,
        component: () => import('@/page/product/secondCarProduct/detail'),
        meta: { title: '金融分期-二手详情', authKey: 'instalment-second-detail', breadCrumb: true }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    sidebar: true,
    meta: { title: '订单管理', icon: 'order', authKey: 'order' },
    children: [
      {
        path: 'list',
        name: 'order',
        sidebar: true,
        component: () => import('@/page/order'),
        meta: { title: '订单管理', icon: 'order', authKey: 'order', breadCrumb: true }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    meta: { title: '订单管理', breadCrumb: true },
    children: [
      {
        path: 'judge/:orderId/:infoFlag',
        name: 'judgeOrder',
        props: true,
        component: () => import('@/page/order/info'),
        meta: { title: '订单审核', authKey: 'judgeOrder', breadCrumb: true }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    meta: { title: '订单管理', breadCrumb: true },
    children: [
      {
        path: 'upload/:orderId/:infoFlag',
        name: 'uploadOrder',
        props: true,
        component: () => import('@/page/order/info'),
        meta: { title: '补充订单材料', authKey: 'uploadOrder', breadCrumb: true }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    meta: { title: '订单管理', breadCrumb: true },
    children: [
      {
        path: 'info/:orderId/:infoFlag',
        name: 'orderInfo',
        props: true,
        component: () => import('@/page/order/info'),
        meta: { title: '订单详情', authKey: 'orderInfo', breadCrumb: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    sidebar: true,
    meta: { title: '用户管理', icon: 'user', authKey: 'user' },
    children: [
      {
        path: 'list',
        name: 'user',
        sidebar: true,
        component: () => import('@/page/user'),
        meta: { title: '用户管理', icon: 'user', authKey: 'user', breadCrumb: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/list',
    meta: { title: '用户管理', breadCrumb: true },
    children: [
      {
        path: 'judge/:userId/:infoFlag',
        name: 'judgeUser',
        props: true,
        component: () => import('@/page/user/info'),
        meta: { title: '用户审核', authKey: 'user-approve', breadCrumb: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/list',
    meta: { title: '用户管理', breadCrumb: true },
    children: [
      {
        path: 'info/:userId/:infoFlag',
        name: 'userInfo',
        props: true,
        component: () => import('@/page/user/info'),
        meta: { title: '用户详情', authKey: 'user-detail', breadCrumb: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '用户详情', authKey: 'user-detail', breadCrumb: true },
    children: [
      {
        path: 'detail/:productId',
        name: 'userSecondCarDetail',
        props: true,
        component: () => import('@/page/product/secondCarProduct/detail'),
        meta: { title: '金融分期-二手详情', authKey: 'instalment-second-detail', breadCrumb: true }
      },
      {
        path: 'modify/:productId',
        name: 'modifyUserSecondCarProduct',
        props: true,
        component: () => import('@/page/product/secondCarProduct/info'),
        meta: { title: '修改金融分期-二手', authKey: 'instalment-second-modify', breadCrumb: true }
      },
      {
        path: 'detail/:productId',
        name: 'userNewCarDetail',
        props: true,
        component: () => import('@/page/product/newCarProduct/detail'),
        meta: { title: '金融分期-新车详情', authKey: 'instalment-new-detail', breadCrumb: true }
      },
      {
        path: 'modify/:productId',
        name: 'modifyUserNewCarProduct',
        props: true,
        component: () => import('@/page/product/newCarProduct/info'),
        meta: { title: '修改金融分期-新车', authKey: 'instalment-new-modify', breadCrumb: true }
      },
      {
        path: 'detail/:productId',
        name: 'userPresentDetail',
        props: true,
        component: () => import('@/page/product/presentProduct/detail'),
        meta: { title: '融资租赁-现车详情', authKey: 'lease-present-detail', breadCrumb: true }
      },
      {
        path: 'modify/:productId',
        name: 'modifyUserPresentProduct',
        props: true,
        component: () => import('@/page/product/presentProduct/info'),
        meta: { title: '修改融资租赁-现车', authKey: 'lease-present-modify', breadCrumb: true }
      }
    ]
  },
  // {
  //   path: '/finance',
  //   component: Layout,
  //   sidebar: true,
  //   meta: { title: '财务管理', icon: 'finance', authKey: 'finance' },
  //   children: [
  //     {
  //       path: 'list',
  //       name: 'finance',
  //       sidebar: true,
  //       component: () => import('@/page/finance'),
  //       meta: { title: '财务管理', icon: 'finance', authKey: 'finance', breadCrumb: true }
  //     }
  //   ]
  // },
  {
    path: '/supplier',
    component: Layout,
    sidebar: true,
    meta: { title: '供应商管理', icon: 'supplier', authKey: 'supplier' },
    children: [
      {
        path: 'list',
        name: 'supplier',
        sidebar: true,
        component: () => import('@/page/supplier'),
        meta: { title: '供应商管理', icon: 'supplier', authKey: 'supplier', breadCrumb: true }
      }
    ]
  },
  {
    path: '/supplier',
    component: Layout,
    redirect: '/supplier/list',
    meta: { title: '供应商管理', breadCrumb: true },
    children: [
      {
        path: 'new',
        name: 'newSupplier',
        component: () => import('@/page/supplier/info'),
        meta: { title: '新增供应商', authKey: 'supplier-new', breadCrumb: true }
      }
    ]
  },
  {
    path: '/supplier',
    component: Layout,
    redirect: '/supplier/list',
    meta: { title: '供应商管理', breadCrumb: true },
    children: [
      {
        path: 'modify/:supplierId/:infoFlag',
        name: 'modifySupplier',
        props: true,
        component: () => import('@/page/supplier/info'),
        meta: { title: '修改供应商', authKey: 'supplier-modify', breadCrumb: true }
      }
    ]
  },
  {
    path: '/supplier',
    component: Layout,
    redirect: '/supplier/list',
    meta: { title: '供应商管理', breadCrumb: true },
    children: [
      {
        path: 'detail/:supplierId/:infoFlag',
        name: 'supplierDetail',
        props: true,
        component: () => import('@/page/supplier/info'),
        meta: { title: '供应商详情', authKey: 'supplier-detail', breadCrumb: true }
      }
    ]
  },
  {
    path: '/news',
    component: Layout,
    sidebar: true,
    meta: { title: '资讯管理', authKey: 'news' },
    children: [
      {
        path: 'list',
        name: 'news',
        sidebar: true,
        component: () => import('@/page/news'),
        meta: { title: '资讯管理', icon: 'news', authKey: 'news', breadCrumb: true }
      }
    ]
  },
  {
    path: '/news',
    component: Layout,
    redirect: '/news/list',
    meta: { title: '资讯管理', breadCrumb: true },
    children: [
      {
        path: 'new',
        name: 'newNews',
        component: () => import('@/page/news/info'),
        meta: { title: '新增资讯', authKey: 'news-new', breadCrumb: true }
      }
    ]
  },
  {
    path: '/news',
    component: Layout,
    redirect: '/news/list',
    meta: { title: '资讯管理', breadCrumb: true },
    children: [
      {
        path: 'modify/:newsId',
        name: 'modifyNews',
        props: true,
        component: () => import('@/page/news/info'),
        meta: { title: '修改资讯', authKey: 'news-modify', breadCrumb: true }
      }
    ]
  },
  {
    path: '/news',
    component: Layout,
    redirect: '/news/list',
    meta: { title: '资讯管理', breadCrumb: true },
    children: [
      {
        path: 'detail/:newsId',
        name: 'newsDetail',
        props: true,
        component: () => import('@/page/news/detail'),
        meta: { title: '资讯详情', authKey: 'news-detail', breadCrumb: true }
      }
    ]
  },
  {
    path: '/download',
    component: Layout,
    sidebar: true,
    meta: { title: '下载', icon: 'download' },
    children: [
      {
        path: '',
        name: 'download',
        sidebar: true,
        component: () => import('@/page/download'),
        meta: { title: '下载', icon: 'download', breadCrumb: true }
      }
    ]
  },
  {
    path: '/error',
    component: Layout,
    redirect: 'noredirect',
    name: 'errorPages',
    meta: {
      title: 'errorPages',
      icon: '404'
    },
    children: [
      {
        path: '401', component: () => import('@/page/errorPage/401'), name: 'page401', meta: { title: 'page401', noCache: true }
      },
      {
        path: '404', component: () => import('@/page/errorPage/404'), name: 'page404', meta: { title: 'page404', noCache: true }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
